'''
第 0016 题： 纯文本文件 numbers.txt, 里面的内容（包括方括号）如下所示：

[
	[1, 82, 65535],
	[20, 90, 13],
	[26, 809, 1024]
]
请将上述内容写到 numbers.xls 文件中
'''

import re
import openpyxl

def txt_to_xlsx():
    f = open(r'D:\numbers.txt')
    f1 = openpyxl.load_workbook(r'D:\numbers.xlsx')
    sheet = f1.get_sheet_by_name('Sheet1')
    rule = re.compile('\w+')
    L = rule.findall(f.read())
    t = 0
    for i in L:
        row = t//3+1
        column = t%3+1
        sheet.cell(row=row, column=column, value=i)
        t += 1
    f1.save(r'D:\numbers.xlsx')

txt_to_xlsx()



